home *** CD-ROM | disk | FTP | other *** search
/ Shoot! / Shoot! (199x)(CD-ROM Update International)(NL)[compilation].iso / jedidemo / episode / jk1mpdem.gob / cog_m4_reactorthrust.cog next >
Text File  |  1999-12-31  |  4KB  |  137 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # M4_reactorthrust.cog
  4. #
  5. # Multiplayer sectorthrust trap.
  6. #
  7. # This script will control 2 sector thrust sectors thrusting in the same direction
  8. # and with the same velocity.  The thrusts activate with a switch.
  9. #
  10. # [IS/JS]
  11. #
  12. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved        
  13. # ========================================================================================
  14.  
  15. symbols
  16.  
  17. message        startup    
  18. message        activate    
  19. message        arrived
  20. message        entered
  21. message        timer    
  22.  
  23. int            currentThing        local
  24. int            i                        local
  25.  
  26. vector        playerVec            local
  27. vector        vec0                    desc=thrust_direction
  28.  
  29. float            thrustspeed=1.0    desc=thrust_speed
  30. float            doorspeed=2.0         desc=speed of the doors
  31. float            sleeptime=2.0        desc=seconds that the doors pause
  32.  
  33. thing            door0                    linkid=2
  34. thing            door1                    nolink
  35. thing            door2                    nolink
  36. thing            door3                    nolink
  37.  
  38. surface        Switch                linkid=1
  39.  
  40. sector        sector0    
  41. sector        sector1    
  42.  
  43. thing            light0                nolink
  44. float            lspeed=4.0            desc=light_speed
  45. sound            wav0
  46. sound            wav1
  47. thing            thing0
  48. float            fadetime=4.0
  49. end
  50.  
  51. # ========================================================================================
  52.  
  53. code
  54. startup:
  55.     SetTimer(0.1);
  56.     channel=PlaySoundThing(wav0, thing0, 0.01, -1, -1, 1);
  57.     return;
  58.     
  59. # ........................................................................................
  60.  
  61. activate:
  62.     if (GetSenderID() != 1) return;
  63.     if (GetWallCel(switch) == 1) return; 
  64.  
  65.     SetWallCel(Switch, 1);
  66.     PlaySoundPos(wav1, SurfaceCenter(switch), 1, -1, -1, 0);
  67.     ChangeSoundVol(channel, 1.5, fadetime/2); 
  68.     ChangeSoundPitch(channel, 1, fadetime/2); 
  69.     MoveToFrame(door0, 1, doorspeed);
  70.     MoveToFrame(door1, 1, doorspeed);
  71.     MoveToFrame(door2, 1, doorspeed);
  72.     MoveToFrame(door3, 1, doorspeed);
  73.     SectorThrust(sector0, vec0, thrustspeed);
  74.     SectorThrust(sector1, vec0, thrustspeed);
  75.     MoveToFrame(light0, 1, lspeed);
  76.  
  77.     // unattach all players in sectors
  78.     currentThing = FirstThingInSector(sector0);
  79.     while (currentThing != -1) {
  80.         call reactorpull;
  81.         currentThing = NextThingInSector(currentThing);
  82.     }
  83.     
  84.     currentThing = FirstThingInSector(sector1);
  85.     while (currentThing != -1) {
  86.         call reactorpull;
  87.         currentThing = NextThingInSector(currentThing);
  88.     }    
  89.     return;
  90.  
  91. # ........................................................................................
  92.  
  93. arrived:  
  94.     if (GetCurFrame(GetSenderRef()) == 0) {
  95.         SetWallCel(switch, 0);
  96.         PlaySoundPos(wav1, SurfaceCenter(switch), 1, -1, -1, 0);
  97.         SectorThrust(sector0, vec0, 0.0);
  98.         SectorThrust(sector1, vec0, 0.0);
  99.     } else {
  100.         MoveToFrame(door0, 0, doorspeed);
  101.         MoveToFrame(door1, 0, doorspeed);
  102.         MoveToFrame(door2, 0, doorspeed);
  103.         MoveToFrame(door3, 0, doorspeed);
  104.         MoveToFrame(light0, 0, lspeed);
  105.         ChangeSoundVol(channel, 0.1, fadetime); 
  106.         ChangeSoundPitch(channel, 0.1, fadetime); 
  107.     }
  108.     
  109.     return;
  110.  
  111. # ........................................................................................
  112.  
  113. timer:
  114.     ChangeSoundPitch(channel, 0.1, 0.1); 
  115.     return;
  116.         
  117. # ........................................................................................
  118.  
  119. entered:
  120.     if (GetSenderId() !=0) return;
  121.     if (GetWallCel(switch) !=1) return;
  122.     currentThing = GetSourceRef();
  123.     // fall through
  124.     
  125. # ........................................................................................
  126.  
  127. reactorpull:
  128.     if (GetThingType(currentThing) == 10) {
  129.         DetachThing(currentThing);
  130.         playerVec = GetThingVel(currentThing);
  131.         playerVec = VectorAdd(vec0, playerVec);
  132.         SetThingVel(currentThing, playerVec);
  133.     }
  134.     return;
  135.  
  136. end
  137.